<%@ page import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>密码修改</title>
<link rel="stylesheet" href="<%=basePath%>/styles/layui.css" />
</head>
<body>
	<form class="layui-form" id="form">
		<div class="layui-form-item">
			<label class="layui-form-label">原密码</label>
			<div class="layui-input-inline">
				<input type="password" name="oldpwd" required
					lay-verify="required" placeholder="请输入密码" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-inline">
				<input type="password" name="newpwd" required
					lay-verify="pass" placeholder="请输入密码" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-inline">
				<input type="password" name="renewpwd" required
					lay-verify="pass" placeholder="请输入密码" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<script type="text/javascript"
		src="<%=basePath%>/javascripts/jquery.min.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>/javascripts/layui.all.js"></script>
	<script>
		//Demo
		layui.use('form', function() {
			var form = layui.form;
			form.verify({
				  pass: [
				    /^[\S]{6,12}$/
				    ,'密码必须6到12位，且不能出现空格'
				  ] 
				});  
			//监听提交
			form.on('submit(formDemo)', function(data) {
				var formData = data.field;
				if(formData['newpwd'] === formData['renewpwd']){
					$.ajax({
						cache : true,
						type : "POST",
						url : "/cloud_note/user/changePwd",
						data : $('#form').serializeArray(),// 你的formid
						async : false,
						error : function(request) {
							layer.msg("服务器内部错误，请联系管理员", {icon: 5});
						},
						success : function(data) {
							layer.msg(data.modelMap.msg,{icon: 1});
						}
					}); 
				}else {
					layer.msg("两次输入的密码不一致！", {icon: 5});
				} 
				return false;
			});
		});
	</script>
</body>
</html>

